<!-- 用户管理 -->
<template>
  <div class="app-container">
    <el-row :gutter="20">
      <!-- 部门树 -->

      <!-- 用户列表 -->
      <el-col :lg="24" :xs="24">
        <div class="topline1">
          <div class="titlel">
            <div class="titlel_box"></div>
            <div class="titlel_tt">差异分析</div>
          </div>
        </div>

        <div class="containers">
          <div class="center1">
            <div class="top1">
              <div class="leftboxs">
                <div
                  @click="activenum = 0"
                  :class="activenum == 0 ? 'leitem activecolor' : 'leitem'"
                >
                  预估工时
                  <div class="activeboder" v-if="activenum == 0"></div>
                </div>
                <div
                  @click="activenum = 1"
                  :class="activenum == 1 ? 'leitem  activecolor' : 'leitem'"
                >
                  实际工时
                  <div class="activeboder" v-if="activenum == 1"></div>
                </div>
                <div
                  @click="activenum = 2"
                  :class="activenum == 2 ? 'leitem  activecolor' : 'leitem'"
                >
                  差异工时
                  <div class="activeboder" v-if="activenum == 2"></div>
                </div>
              </div>
              <el-button class="daochubtn">
                <el-icon><Upload /></el-icon>
                <span>导出</span>
              </el-button>
            </div>
            <div class="msgbox" v-if="false">
              <img src="/src/assets/images/Group@2x.png" alt="" />
              <span>暂无数据内容展示，选择人员后查看列表</span>
            </div>
            <el-table
              :data="tableData"
              style="max-width: 100%; margin-bottom: 18px"
              :span-method="arraySpanMethod"
              :header-cell-style="tableHeaderStyle"
              :cell-style="tableHeaderStyle1"
            >
              <el-table-column label="序号" align="center" fixed width="69">
                <template #default="scope">
                  <div
                    v-if="
                      scope.$index != tableData.length - 1 &&
                      scope.$index != tableData.length - 2 &&
                      scope.$index != tableData.length - 3
                    "
                  >
                    {{ scope.row.id }}
                  </div>

                  <div
                    style="display: flex; width: 100%; color: #1d2129"
                    v-if="scope.$index == tableData.length - 2"
                  >
                    <span>{{ scope.row.id }}</span>
                  </div>
                  <div
                    style="display: flex; width: 100%; color: #f53f3f"
                    v-if="scope.$index == tableData.length - 1"
                  >
                    <span>{{ scope.row.id }}</span>
                  </div>
                </template>
              </el-table-column>
              <el-table-column
                prop="yijiclassname"
                align="center"
                label="一级项目"
                fixed
                width="130"
              />
              <el-table-column align="center" label="二级项目" fixed width="130" />
              <el-table-column label="周一" align="center">
                <el-table-column prop="ondeaty" label="1" min-width="58" align="center">
                  <template v-slot:header>
                    <span>12</span>
                    <img
                      src="/src/assets/images/Frame@2x(1).png"
                      style="
                        position: absolute;
                        width: 14px;
                        height: 14px;
                        right: 0%;
                        bottom: 0%;
                        cursor: pointer;
                      "
                      @click="addopen('备注')"
                      alt=""
                    />
                  </template>
                </el-table-column>
              </el-table-column>
              <el-table-column label="周二" align="center">
                <el-table-column prop="ondeaty" label="1" width="58" align="center">
                  <template #default="scope">
                    <el-input v-model="scope.row.val" type="text" v-if="scope.row.bool" />
                    <span v-else>1</span>
                  </template>
                </el-table-column>
              </el-table-column>
              <el-table-column label="周三">
                <el-table-column prop="ondeaty" label="1" width="58" align="center">
                  <template #default="scope">
                    <el-input v-model="scope.row.val" type="text" v-if="scope.row.bool" />
                    <span v-else>1</span>
                  </template>
                </el-table-column>
              </el-table-column>
              <el-table-column label="周四">
                <el-table-column prop="ondeaty" label="1" width="58" align="center">
                  <template #default="scope">
                    <el-input v-model="scope.row.val" type="text" v-if="scope.row.bool" />
                    <span v-else>1</span>
                  </template>
                </el-table-column>
              </el-table-column>
              <el-table-column label="周五">
                <el-table-column prop="ondeaty" label="1" width="58" align="center" />
              </el-table-column>
              <el-table-column label="周六">
                <el-table-column prop="ondeaty" label="1" index="1" width="58" align="center" />
              </el-table-column>
              <el-table-column label="周日">
                <el-table-column prop="ondeaty" label="1" index="1" width="58" align="center" />
              </el-table-column>
              <el-table-column label="周一" align="center">
                <el-table-column prop="ondeaty" label="1" width="58" align="center">
                  <template v-slot:header>
                    <span>1</span>
                  </template>
                </el-table-column>
              </el-table-column>
              <el-table-column label="周二" align="center">
                <el-table-column prop="ondeaty" label="1" width="58" align="center" />
              </el-table-column>
              <el-table-column label="周三">
                <el-table-column prop="ondeaty" label="1" width="58" align="center" />
              </el-table-column>
              <el-table-column label="周四">
                <el-table-column prop="ondeaty" label="1" width="58" align="center" />
              </el-table-column>
              <el-table-column label="周五">
                <el-table-column prop="ondeaty" label="1" width="58" align="center" />
              </el-table-column>
              <el-table-column label="周六">
                <el-table-column prop="ondeaty" label="1" index="1" width="58" align="center" />
              </el-table-column>
              <el-table-column label="周日">
                <el-table-column prop="ondeaty" label="1" index="1" width="58" align="center" />
              </el-table-column>
              <el-table-column label="周一" align="center">
                <el-table-column prop="ondeaty" label="1" width="58" align="center" />
              </el-table-column>
              <el-table-column label="周二" align="center">
                <el-table-column prop="ondeaty" label="1" width="58" align="center" />
              </el-table-column>
              <el-table-column label="周三">
                <el-table-column prop="ondeaty" label="1" width="58" align="center" />
              </el-table-column>
              <el-table-column label="周四">
                <el-table-column prop="ondeaty" label="1" width="58" align="center" />
              </el-table-column>
              <el-table-column prop="heji" align="center" label="合计" fixed="right" width="130" />
              <el-table-column label="操作" fixed="right" align="center" width="118">
                <template #default="scope">
                  <div>
                    <span
                      style="font-weight: 400; font-size: 16px; color: #165dff; cursor: pointer"
                      @click="gopage"
                      v-if="scope.$index != 7 && scope.$index != 6"
                    >
                      {{ activenum == 2 ? "详情 |" : "详情" }}
                    </span>

                    <span
                      style="font-weight: 400; font-size: 16px; color: #165dff; cursor: pointer"
                      @click="scope.row.bool = !scope.row.bool"
                      v-if="scope.$index != 7 && scope.$index != 6 && activenum == 2"
                    >
                      说明
                    </span>
                  </div>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
      </el-col>
    </el-row>
    <el-dialog v-model="popubool" :show-close="false" width="39.625rem" :modal="false" center>
      <template #header>
        <div class="popubox" v-if="typestr == '备注'">
          <div class="backtop">
            <div class="topline">
              <div class="text">详情</div>
              <img
                src="/src/assets/images/微信图片_20250903150026_21_215.png"
                @click="popubool = false"
                alt=""
              />
            </div>
          </div>
          <el-input
            v-model="textarea2"
            class="textareaname"
            type="textarea"
            placeholder="请输入备注内容"
          />
          <div class="btnss">
            <el-button class="qxbtn" @click="popubool = false" plain>取消</el-button>
            <el-button class="backg" @click="save">保存</el-button>
          </div>
        </div>
        <div class="popubox" v-if="typestr == '添加工时'">
          <div class="backtop">
            <div class="topline">
              <div class="text">添加工时</div>
              <img
                src="/src/assets/images/微信图片_20250903150026_21_215.png"
                @click="popubool = false"
                alt=""
              />
            </div>
          </div>
          <div class="gshibox">
            <div class="usegsbox">
              <img src="/src/assets/images/Frame@2x(6).png" alt="" />
              <span>使用工时模版</span>
            </div>

            <div class="usegsbox" style="margin-top: 26px" @click="gopage('独立创建')">
              <img src="/src/assets/images/Frame@2x(7).png" alt="" />
              <span>独立创建</span>
            </div>
          </div>
        </div>

        <div class="popubox" v-if="typestr == '独立创建'">
          <div class="backtop">
            <div class="topline">
              <div class="text">添加工时</div>
              <img
                src="/src/assets/images/微信图片_20250903150026_21_215.png"
                @click="popubool = false"
                alt=""
              />
            </div>
          </div>
          <div class="gshibox">
            <div class="usegsbox">
              <img src="/src/assets/images/Frame@2x(6).png" alt="" />
              <span>使用工时模版</span>
            </div>

            <div class="xztime">
              <div class="lable">选择日期</div>
              <div class="custom-date-picker-container">
                <el-date-picker type="date" placeholder="请选择" />
              </div>
            </div>
          </div>

          <div class="btnss">
            <el-button class="qxbtn" @click="popubool = false" plain>取消</el-button>
            <el-button class="backg">确定</el-button>
          </div>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from "vue-router";
const router = useRouter();
const activenum = ref(0);
const popubool = ref(false);
const typestr = ref("");
const options = [
  {
    value: "Option1",
    label: "Option1",
  },
  {
    value: "Option2",
    label: "Option2",
  },
  {
    value: "Option3",
    label: "Option3",
  },
  {
    value: "Option4",
    label: "Option4",
  },
  {
    value: "Option5",
    label: "Option5",
  },
];

const tableData = [
  {
    id: 1,
    yijiclassname: "公共假期",
    ondeaty: 1,
    heji: 8,
  },
  {
    id: 2,
    yijiclassname: "病假",
    ondeaty: 1,
    heji: 8,
  },
  {
    id: 3,
    yijiclassname: "年假",
    ondeaty: 1,
    heji: 8,
  },
  {
    id: 4,
    yijiclassname: "丧假",
    ondeaty: 1,
    heji: 8,
  },
  {
    id: 5,
    yijiclassname: "考试假",
    ondeaty: 1,
    heji: 8,
  },
  {
    id: 6,
    yijiclassname: "额外假期",
    ondeaty: 1,
    heji: 8,
  },
  {
    id: "合计",
    ondeaty: 1,
    heji: 8,
  },
  {
    id: "加减小时",
    ondeaty: 1,
    heji: 8,
  },
];
const query = reactive({
  value: "",
  value1: "",
  value2: "",
});
function addopen(str) {
  typestr.value = str;
  popubool.value = true;
}
const tableRowClassName = ({ row, rowIndex }) => {
  console.log(row, "row-----------");

  if (rowIndex === 1) {
    return "warning-row";
  } else if (rowIndex === 3) {
    return "success-row";
  }
  return "";
};
const arraySpanMethod = ({ row, column, rowIndex, columnIndex }: SpanMethodProps) => {
  if (rowIndex === tableData.length - 1 || rowIndex === tableData.length - 2) {
    if (columnIndex === 0) {
      return [1, 3];
    } else if (columnIndex === 1) {
      return [0, 0];
    } else if (columnIndex === 2) {
      return [0, 0];
    }
  }
};
function tableHeaderStyle({ row, rowIndex, column, columnIndex }) {
  if (column.rowSpan == 1) {
    console.log(column);

    if (column.index == "1") {
      return { background: "#21A193", color: "#fff" };
    }

    if (column.label == "周六" || column.label == "周日")
      return { background: "#21A193", color: "#fff" };
  }
}
function save() {
  ElMessageBox.confirm("已保存", "", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "success",
  }).then(
    () => {
      loading.value = true;
      RoleAPI.deleteByIds(roleIds)
        .then(() => {})
        .finally(() => (loading.value = false));
    },
    () => {
      ElMessage.info("已取消删除");
    }
  );
}
function submit() {
  ElMessageBox.confirm("需要添加差异说明", "", {
    confirmButtonText: "添加说明",
    cancelButtonText: "取消",
    type: "warning",
  }).then(
    () => {
      loading.value = true;
      RoleAPI.deleteByIds(roleIds)
        .then(() => {
          ElMessage.success("删除成功");
          handleResetQuery();
        })
        .finally(() => (loading.value = false));
    },
    () => {
      ElMessage.info("已取消删除");
    }
  );
}
function tableHeaderStyle1({ row, rowIndex, column, columnIndex }) {
  console.log(rowIndex, "row-----------");
  if (rowIndex == 7) {
    return { color: "#F53F3F" };
  }
  if (rowIndex == 6) {
    return { color: "#1D2129", "font-weight": "bold" };
  }
}

function gopage(str) {
  if (str == "独立创建") {
    router.push({ name: "CreateIndependently" });
    return;
  }
  router.push({ name: "manHourdetial" });
}
</script>
<style lang="scss" scoped>
::v-deep .custom-date-picker-container {
  position: relative;
  width: 9.75rem;
  margin-right: 24px;
  .el-input__wrapper {
    background-color: #edf1fc !important;
    box-shadow: none !important;
    text-align: right;
    margin-right: 30px;
  }
  .el-input {
    background-color: #edf1fc !important;
  }
  .el-input__inner {
    text-align: right;
  }
}

.custom-date-picker-container :deep(.el-input__prefix) {
  display: none !important;
}

.custom-date-picker-container :deep(.el-input__suffix) {
  left: 12px;
  right: auto;
}

.custom-date-picker-container::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  background-image: url("/src/assets/images/微信图片_20250904101932_36_215.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
  z-index: 2;
}
.gshibox {
  width: 503px;
  margin: auto;
  overflow: hidden;
  margin-top: 36px;
  .xztime {
    width: 503px;
    height: 66px;
    background: #edf1fc;
    border-radius: 8px 8px 8px 8px;
    margin-top: 23px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .lable {
      font-family:
        PingFang SC,
        PingFang SC;
      font-weight: 500;
      font-size: 20px;
      color: #003779;
      margin-left: 24px;
    }
  }
  .usegsbox {
    width: 100%;
    height: 101px;
    background: #f7f8fa;
    border-radius: 6px 6px 6px 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family:
      PingFang SC,
      PingFang SC;
    font-weight: bold;
    font-size: 20px;
    color: #4e5969;
    img {
      width: 44px;
      height: 44px;
      margin-right: 16px;
    }
  }
}
::v-deep .el-textarea {
  .el-textarea__inner {
    resize: none; // 去除右下角图标
  }
}

.textareaname {
  width: 37.125rem;
  height: 12.875rem;
  margin: auto;
  background: #f7f8fa;
  border-radius: 10px 10px 10px 10px;
  margin-top: 19px;
  padding: 14px;
  ::v-deep .el-textarea__inner {
    background: #f7f8fa;
    box-shadow: none;
  }
}
::v-deep .el-dialog--center {
  padding: 0 !important;
}
::v-deep .el-dialog__header {
  border: none !important;
  padding: 0 !important;
}
.popubox {
  width: 100%;
  overflow: hidden;

  .btnss {
    width: 31.4375rem;
    margin: auto;
    margin-top: 24px;
    display: flex;
    justify-content: flex-end;
    align-content: center;
    .qxbtn {
      width: 113px;
      height: 36px;
      text-align: center;
      line-height: 36px;
      font-size: 15px;
    }
    .backg {
      width: 113px;
      height: 36px;
      background: #003779;
      text-align: center;
      line-height: 36px;
      font-size: 15px;
      color: #ffffff;
    }
  }
  .qdbtn {
    width: 113px;
    height: 44px;
    background: #003779;
    border-radius: 6px 6px 6px 6px;
    text-align: center;
    line-height: 44px;
    font-family:
      PingFang SC,
      PingFang SC;
    font-weight: 400;
    font-size: 15px;
    color: #ffffff;
    margin-left: 789px;
    margin-top: 24px;
  }
  .backtop {
    width: 100%;
    height: 54px;
    background: #e5e6eb;
    display: flex;
    align-items: center;
    .topline {
      width: 37.125rem;
      margin-left: 2rem;
      display: flex;
      justify-content: space-between;
      .text {
        font-family:
          PingFang SC,
          PingFang SC;
        font-weight: bold;
        font-size: 18px;
        color: #4e5969;
      }
      img {
        width: 24px;
        height: 24px;
        cursor: pointer;
      }
    }
  }
}
.msgbox {
  width: 35.875rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family:
    PingFang SC,
    PingFang SC;
  font-weight: 400;
  font-size: 1.25rem;
  margin: 45px auto;
  color: #003779;
  img {
    width: 35.875rem;
    height: 28.25rem;
    margin-bottom: 50px;
  }
}
.topline1 {
  width: 100%;
  display: flex;
  justify-content: space-between;
  .btnss {
    display: flex;
    align-items: center;
    .el-button {
      width: 112px;
      height: 44px;
      font-size: 15px;
    }
  }
  .titlel {
    width: 100%;
    display: flex;
    align-items: center;
    .titlel_box {
      width: 4px;
      height: 23px;
      background: #003779;
      border-radius: 0px 6px 6px 0px;
    }
    .titlel_tt {
      font-family:
        PingFang SC,
        PingFang SC;
      font-weight: bold;
      font-size: 1.375rem;
      color: #1d2129;
      margin-left: 9px;
    }
  }
}

.containers {
  width: 100%;
  background: #ffffff;
  overflow: hidden;
  border-radius: 16px 16px 16px 16px;
  margin-top: 20px;
  padding: 0 24px;
}
.containers .center1 {
  margin-top: 19px;
}
::v-deep .el-table thead th {
  background: #f2f3f5;
  color: #1d2129;
}
.top1 {
  width: 100%;
  display: flex;
  justify-content: space-between;
}
.top1 .leftboxs {
  display: flex;
  align-items: center;
}
.leitem {
  font-family:
    PingFang SC,
    PingFang SC;
  font-weight: 400;
  font-size: 1.25rem;
  color: #4e5969;
  position: relative;
  margin-right: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}
.activecolor {
  color: #055fe4 !important;
  font-weight: bold;
}
.activeboder {
  position: absolute;
  width: 3.5rem;
  height: 3px;
  background: #055fe4;
  border-radius: 2px 2px 2px 2px;
  bottom: -10px;
}
.containerr {
  width: 100%;
  height: 80px;
  background: #ffffff;
  border-radius: 12px 12px 12px 12px;
  display: flex;
  margin-bottom: 20px;
  align-items: center;
  margin-top: 24px;
}
.daochubtn {
  width: 7rem;
  height: 2.75rem;
  border-radius: 6px 6px 6px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family:
    PingFang SC,
    PingFang SC;
  font-weight: 400;
  font-size: 0.9375rem;
}
.daochubtn img {
  width: 1rem;
  height: 1rem;
}
.containerr .el-button {
  width: 7.0625rem;
  height: 2.75rem;
  // background: #edf1fc;
  margin-left: 1.25rem;
  display: flex;
  justify-content: center;
  align-items: center;
  img {
    width: 17px;
    height: 17px;
  }
}
.containerr {
  ::v-deep .el-input__wrapper {
    background: #f7f8fa;
    box-shadow: none !important;
  }
}

.borderline {
  width: 19px;
  height: 1px;
  background: #86909c;
  border-radius: 1px 1px 1px 1px;
}
::v-deep .el-date-editor.el-input {
  width: 156px;
  height: 44px;
  background: #f7f8fa;
  border-radius: 6px 6px 6px 6px;
}
.timebox {
  display: flex;
  align-items: center;
  margin-left: 22px;
  width: 361px;
  justify-content: space-between;
}
.el-select {
  width: 18.6875rem;
  border-radius: 6px 6px 6px 6px;
  margin-left: 20px;
  display: flex;
  align-items: center;
}
::v-deep .el-select--large .el-select__wrapper {
  width: 18.6875rem;
  height: 2.75rem;
  background: #f7f8fa;
  border-radius: 6px 6px 6px 6px;
  border: none !important;
  box-shadow: none;
}
.el-table {
  margin-top: 35px;
}
</style>
